#
include(core/CMakeLists.txt)
include(fsm/CMakeLists.txt)
set(GAMESERVER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

set(MAIN_CPP main.cpp
    ${CORE_CPP}
    ${FSM_CPP}
    proto/msg.pb.cc
)

set(MAIN_H
    ${CORE_H}
    ${FSM_H}
    proto/msg.pb.h
)
# 指定生成工程按集合组织代码
source_group(maincpp FILES ${MAIN_CPP})
source_group(mainh FILES ${MAIN_H})

# 指定生成exe程序
add_executable(GameServer ${MAIN_CPP} ${MAIN_H})

add_subdirectory(${PRJ_ROOT_PATH}/3rd/lua ${PROJECT_BINARY_DIR}/3rd)
target_link_libraries(GameServer plainlua)

target_link_directories(GameServer
    PUBLIC ${PRJ_ROOT_PATH}/lib
)
if (WINDOWS)
    target_link_libraries(GameServer libprotobuf.lib)
else()
    target_link_libraries(GameServer libprotobuf.a)
endif()

target_include_directories(GameServer
    PUBLIC ${GAMESERVER_ROOT_PATH}
    PUBLIC ${GAMESERVER_ROOT_PATH}/core
    PUBLIC ${PRJ_ROOT_PATH}/3rd
)


set_target_properties(GameServer
    PROPERTIES
    ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
    FOLDER "Internal"
)

c_get_resource_path(APP_RES_DIR GameServer)
c_sync_folder(GameServer ${res_res_folders} ${APP_RES_DIR}/res)
c_sync_folder(GameServer ${res_src_folders} ${APP_RES_DIR}/luasrc)